package atguigu.ScadaEquipCheckNodeInfoUtils;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.JSONObject;

import cn.hutool.core.io.FileUtil;

public class Main3 {

	public static void main(String[] args) {

		String aCode  
			= "A2211080009200011,压缩机耐久试验台2015A,22110800090056;" + 
			  "A2211080009200012,压缩机耐久试验台2015B,22110800090056;" + 
			  "A2211080009200013,压缩机耐久试验装置2030A,22110800090060;";

		String checkNode = 
		"22110800090001010101,电流_工位1;" + 
		"22110800090001010102,排气压力_工位1;" + 
		"22110800090001010103,吸气压力_工位1;" + 
		"22110800090001010104,排气温度_工位1;" + 
		"22110800090001010105,吸气温度_工位1;" + 
		"22110800090001010106,壳体温度_工位1;" + 
		"22110800090001010107,频率_工位1;" + 
		"22110800090001010201,电流_工位2;" + 
		"22110800090001010202,排气压力_工位2;" + 
		"22110800090001010203,吸气压力_工位2;" + 
		"22110800090001010204,排气温度_工位2;" + 
		"22110800090001010205,吸气温度_工位2;" + 
		"22110800090001010206,壳体温度_工位2;" + 
		"22110800090001010207,频率_工位2;" + 
		"22110800090001010301,电流_工位3;" + 
		"22110800090001010302,排气压力_工位3;" + 
		"22110800090001010303,吸气压力_工位3;" + 
		"22110800090001010304,排气温度_工位3;" + 
		"22110800090001010305,吸气温度_工位3;" + 
		"22110800090001010306,壳体温度_工位3;" + 
		"22110800090001010307,频率_工位3;" + 
		"22110800090001010401,电流_工位4;" + 
		"22110800090001010402,排气压力_工位4;" + 
		"22110800090001010403,吸气压力_工位4;" + 
		"22110800090001010404,排气温度_工位4;" + 
		"22110800090001010405,吸气温度_工位4;" + 
		"22110800090001010406,壳体温度_工位4;" + 
		"22110800090001010407,频率_工位4;" + 
		"22110800090001010501,电流_工位5;" + 
		"22110800090001010502,排气压力_工位5;" + 
		"22110800090001010503,吸气压力_工位5;" + 
		"22110800090001010504,排气温度_工位5;" + 
		"22110800090001010505,吸气温度_工位5;" + 
		"22110800090001010506,壳体温度_工位5;" + 
		"22110800090001010507,频率_工位5;" + 
		"22110800090001010601,电流_工位6;" + 
		"22110800090001010602,排气压力_工位6;" + 
		"22110800090001010603,吸气压力_工位6;" + 
		"22110800090001010604,排气温度_工位6;" + 
		"22110800090001010605,吸气温度_工位6;" + 
		"22110800090001010606,壳体温度_工位6;" + 
		"22110800090001010607,频率_工位6;" + 
		"22110800090001010701,电流_工位7;" + 
		"22110800090001010702,排气压力_工位7;" + 
		"22110800090001010703,吸气压力_工位7;" + 
		"22110800090001010704,排气温度_工位7;" + 
		"22110800090001010705,吸气温度_工位7;" + 
		"22110800090001010706,壳体温度_工位7;" + 
		"22110800090001010707,频率_工位7;" + 
		"22110800090001010801,电流_工位8;" + 
		"22110800090001010802,排气压力_工位8;" + 
		"22110800090001010803,吸气压力_工位8;" + 
		"22110800090001010804,排气温度_工位8;" + 
		"22110800090001010805,吸气温度_工位8;" + 
		"22110800090001010806,壳体温度_工位8;" + 
		"22110800090001010807,频率_工位8;" + 
		"22110800090001010901,电流_工位9;" + 
		"22110800090001010902,排气压力_工位9;" + 
		"22110800090001010903,吸气压力_工位9;" + 
		"22110800090001010904,排气温度_工位9;" + 
		"22110800090001010905,吸气温度_工位9;" + 
		"22110800090001010906,壳体温度_工位9;" + 
		"22110800090001010907,频率_工位9;" + 
		"22110800090001011001,电流_工位10;" + 
		"22110800090001011002,排气压力_工位10;" + 
		"22110800090001011003,吸气压力_工位10;" + 
		"22110800090001011004,排气温度_工位10;" + 
		"22110800090001011005,吸气温度_工位10;" + 
		"22110800090001011006,壳体温度_工位10;" + 
		"22110800090001011007,频率_工位10;";

		String[] split = aCode.split(";");
		String[] split3 = checkNode.split(";");
		FileUtil.appendString("[", "D://ScadaEquipCheckNodeInfo1.txt", "UTF-8");
		for (int i = 0; i < split.length; i++) {
			if(StringUtils.isNotBlank(split[i])) {
				String[] split2 = split[i].trim().split(",");
				for (int j = 0; j < split3.length; j++) {
					ScadaEquipCheckNodeInfo info = new ScadaEquipCheckNodeInfo();
					info.setaCode(split2[0].trim());
					info.setEquipmentName(split2[1].trim());
					info.setSampleModel(split2[2].trim());
					if (StringUtils.isNotBlank(split3[j])) {
						String[] split4 = split3[j].split(",");
						info.setCheckNodeId(split4[0].trim());
						String[] split5 = split4[1].split("_");
						info.setCheckNodeType(split5[0].trim());
						info.setWorkLocation(split5[1].trim());
						info.initEquipmentNo();
//						System.out.println(JSONObject.toJSONString(info) + ",");
						FileUtil.appendString(JSONObject.toJSONString(info) + ",", "D://ScadaEquipCheckNodeInfo1.txt", "UTF-8");
					}
				}
			}
		}
		FileUtil.appendString("]", "D://ScadaEquipCheckNodeInfo1.txt", "UTF-8");
		System.out.println("结束");
	}
}
